<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>用户信息更新</title>
</head>
<body>
	<div class="form-container">
        <form id="providerForm">
            <table class="info-table">
            <tr>
			<td><label>用户编号</label></td>
			<td><label>${user.userId }</label></td>
			</tr>
			<tr>
				<td><label>用户名</label></td>
				<td><input type="text" name="username" id="username" value="${user.username }"></td>
			</tr>
			<tr>
				<td><label>电话</label></td>
				<td><input type="text" name="phone" id = "phone" value="${user.phone }"></td>
			</tr>
			<tr>
			<td><label>权限</label></td>
			<td><label>${user.roleId }</label></td>
			</tr>
			<tr>
				<td colspan="2"><input type="button" value="保存" id="sub"></td>
			</tr>	
			<tr>
				<td colspan="2"><input type="hidden" id="userId" value="${user.userId }"></td>
			</tr>
			<tr>
				<td colspan="2"><input type="hidden" id="roleId" value="${user.roleId }"></td>
			</tr>
					
	</table>
	</form>
	</div>
<script src="../js/jquery.min.js"></script>
<script src="../js/layer/layer.js"></script>
<script>
$(document).ready(function() {
    $('#sub').click(function() {
        var userId = $('#userId').val();
        var username = $('#username').val();
        var phone = $('#phone').val();
        var roleId = $('#roleId').val();
        $.post('AdminUpdateUserServlet', {
        	userId: userId,
        	username: username,
        	phone: phone,
        	roleId: roleId
        }, function(data) {
            switch(data) {
                case 'OK':
                    layer.msg('修改成功');
                    move();
                    break;
                case 'Error2':
                    layer.alert('该手机号已经注册');
                    break;
                default:
                    layer.msg('修改失败');
                    break;
            }
        });
    });
});

function move() {
    window.location.href = 'AdminUserServlet';
}
</script>
</body>
</html>